﻿using System;
using System.Collections.Generic;
using System.Linq;

/// <summary>
/// Contains extension methods for <see cref="T:System.Collections.IEnumerable{T}"/>.
/// </summary>
public static class OneThousandEnumerables
{
    /// <summary>
    /// Returns a value indicating whether a collecion has at least ONE THOUSAND items.
    /// </summary>
    /// <typeparam name="T">Type of the item.</typeparam>
    /// <param name="items">The items.</param>
    /// <returns>
    /// True if the collection as at least ONE THOUSAND items; otherwise false.
    /// </returns>
    public static bool HasAtLeastOneThousand<T>(this IEnumerable<T> items)
    {
        if (items == null)
            throw new ArgumentNullException("items");

        return items.Take(OneThousand.Value).Count() == OneThousand.Value;
    }
    /// <summary>
    /// Returns a value indicating whether a collecion has at least ONE THOUSAND items.
    /// </summary>
    /// <typeparam name="T">Type of the item.</typeparam>
    /// <param name="items">The items.</param>
    /// <returns>
    /// True if the collection as at least ONE THOUSAND items; otherwise false.
    /// </returns>
    public static bool HasExactlyOneThousand<T>(this IEnumerable<T> items)
    {
        if (items == null)
            throw new ArgumentNullException("items");

        return items.Take(OneThousand.Value + 1).Count() == OneThousand.Value;
    }
    /// <summary>
    /// Returns a <see cref="OneThousandList{T}"/> containing the set of items.
    /// </summary>
    /// <typeparam name="T">Type of the item.</typeparam>
    /// <param name="items">The items.</param>
    /// <returns>
    /// New <see cref="OneThousandList{T}"/> containing the set of items.
    /// </returns>
    public static OneThousandList<T> ToOneThousandList<T>(this IEnumerable<T> items)
    {
        if (items == null)
            throw new ArgumentNullException("items");

        return new OneThousandList<T>(items);
    }
}
